<?php

namespace Xrfg\Api\Trading\Spot\Listeners;

use Xrfg\Api\Trading\Spot\Events\OrderCreatedEvent;
use Xrfg\Api\Trading\Spot\Jobs\MatchJob;
use Xrfg\Core\Trading\Spot\Models\Order;

class DispatchMatchJob
{
    public function handle(OrderCreatedEvent $event)
    {
        /** @var Order $order */
        $order = $event->order;
        if (!$order->exists) {
            return;
        }

        MatchJob::dispatch($order->symbol)->onQueue('match:'.$order->symbol);
    }
}
